from dataclasses import dataclass, field
from typing import List

from numba.core.cgutils import printf


@dataclass
class Student:
    name: str
    age: int
    grades: List[float] = field(default_factory=list)

    def average(self):
        return sum(self.grades) / len(self.grades) if self.grades else 0


# 创建示例
student = Student("小王", 18, [90, 85, 75])
print(student)
print(f"{student.average():.2f}")